package kr.saeildamil.project.secretary;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.LinearInterpolator;
import android.view.animation.TranslateAnimation;
import android.widget.LinearLayout;

public class Loading extends Activity {
	LinearLayout load;
	AnimationSet loadingAni;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Window win=getWindow();
		win.requestFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.loading);
		
		load=(LinearLayout) findViewById(R.id.loading_btnlayout);

		loadAnimation();
	}
	
	private void loadAnimation() {
		loadingAni=new AnimationSet(true);
		loadingAni.setInterpolator(new LinearInterpolator());
		
		TranslateAnimation trans=
				new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0, 
									   Animation.RELATIVE_TO_PARENT, -1, Animation.RELATIVE_TO_PARENT, 0);
		trans.setDuration(800);
		loadingAni.addAnimation(trans);
		
		AlphaAnimation alpha=new AlphaAnimation(0, 1);
		alpha.setDuration(800);
		alpha.setStartOffset(250);
		loadingAni.addAnimation(alpha);
		
		load.startAnimation(loadingAni);
	}
	
	public void mOnClick(View v){
		switch (v.getId()) {
		case R.id.gomain_btn:
			startActivity(new Intent(this, Main.class));
			break;
		case R.id.firstsetup_btn:
			startActivity(new Intent(this, Setup.class));
			break;
		}
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
}
